<?php
require_once("../lib/DbWrapper.class.php");
require("../libs/Smarty.class.php");
require("../libs/myUtil.class.php");
$smarty = new Smarty;

DbWrapper::dbChoice();

$sql = "SELECT count(*) FROM comment";
$result = mysql_query($sql);
$row = mysql_fetch_row($result);
//generatePager関数を実行すると、pagerを形作るのに必要な要素が配列で帰ってくる
$pager = myUtil::generatePager(10,$row[0],$_GET["page"],"","/bbs/admin/");
$smarty->assign("pager", $pager);

$sql ="SELECT * FROM comment ORDER BY created_at DESC LIMIT ".$pager["num_s"].",".$pager["num_e"];
//LIMITで範囲指定
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
        $rows[] = $row;
}
$smarty->assign("rows",$rows);

//sessionのクリア
session_start();
$_SESSION["tmpphoto"] = "";
$_SESSION["tmpnickname"] ="";
$_SESSION["tmpcontent"] ="";
$_SESSION["temcategory_id"] = "";
$_SESSION["tempurl"] = "";

print_r($_SESSION);
//↑コメント編集の確認画面における戻る機能の実装のため

$smarty->display("comment_list.tpl");